home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Aminet 15
/
Aminet 15 - Nov 1996.iso
/
Aminet
/
disk
/
cdrom
/
Atapi_PnP300.lha
/
atapi_pnp300
/
developer_kit
/
PlayLSN.c
< prev
next >
Wrap
C/C++ Source or Header
|
1996-01-27
|
3KB
|
92 lines
/****************************************************************************
*
*
* $VER: PlayLSN.c 1.0 (22 Jan 1996) by M_Campinoti CD++
*
* $HISTORY:
*
* 22 Jan 1996 : 001.000 : First and Last release of an example that show
* how to play audio tracks by means of
* CD_PLAYLSN command.
* Didactical use, so CLI only :)
*
****************************************************************************/
#include <proto/exec.h>
#include <exec/devices.h>
#include <exec/io.h>
#include <stdio.h>
#include <stdlib.h>
#include "atapi_cd.h"
/**********************************************************************************/
/* Here the fornula to calculate the right LSN starting by Minutes,Seconds,Frames */
/* Length = minutes*(60*75) + seconds*75 + frames */
/* */
/* minutes , seconds , frames to play (default 1m,1sec,1fr) */
#define DEF_LENGTH ( 01*(60*75) + 01*75 + 01)
/**********************************************************************************/
main (UBYTE argc,UBYTE** argv)
{
struct IOStdReq *ioreq = NULL ;
struct MsgPort *reply = NULL ;
ULONG lsn_start;
ULONG lsn_length;
switch(argc)
{
case 0:
return; /* it came from workbench .... */
break;
case 1:
printf("USAGE: PlayLSN <LSN_start> <LSN_Length>\n");
return; /* Yes, this isn't a cool template, but is quickly ! (i'm lazy) */
break;
case 2:
lsn_start=atoi(argv[1]);
lsn_length=DEF_LENGTH;
break;
case 3:
lsn_start=atoi(argv[1]);
lsn_length=atoi(argv[2]);
default:
break;
}
if( reply = CreateMsgPort() )
{
if( ioreq = (struct IOStdReq *)
CreateIORequest(reply ,sizeof(struct IOStdReq)) )
{
if(!OpenDevice("cd.device",0,(struct IORequest*)ioreq,NULL) )
{
ioreq->io_Command = CD_PLAYLSN;
ioreq->io_Offset = lsn_start;
ioreq->io_Length = lsn_length;
SendIO((struct IORequest*)ioreq);
if (!ioreq->io_Error) /* Command succeeded */
{
printf("Start Playing at requested LSN ...\n");
WaitIO((struct IORequest*)ioreq);
}
else printf("I/O error !\n"); /* analyze ioreq->io_Error to know what kind ... */
/* ... see atapi_cd.h for #defines of it ! */
CloseDevice((struct IORequest *)ioreq) ;
}
DeleteIORequest(ioreq) ;
}
DeleteMsgPort(reply);
}
}